package com.lbs.jiepiaisi;

import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

import com.lbs.jiepiaisi.activity.SignTextActivity;
import com.lbs.jiepiaisi.activity.WorkHomeOrderAddActivity;
import com.lbs.jiepiaisi.base.BaseActivity;

import java.io.File;

public class TestSignActivity extends BaseActivity {
    Button btn2;
    ImageView img2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test_sign);
        findView();
        setListener();
    }
    public void findView(){

        btn2 = (Button)findViewById(R.id.btn2);

        img2 = (ImageView) findViewById(R.id.img2);

    }
    public void setListener(){
        btn2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivityForResult(new Intent(TestSignActivity.this, TestSignActivity.class), 1);
            }
        });
    }


    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (resultCode == 100) {
//            BitmapFactory.Options options = new BitmapFactory.Options();
//            options.inSampleSize = 2;
//            Bitmap bm = BitmapFactory.decodeFile(path, options);
//            img1.setImageBitmap(bm);
        } else if (resultCode == 101) {
            BitmapFactory.Options options = new BitmapFactory.Options();
            options.inSampleSize = 2;
            Bitmap bm = BitmapFactory.decodeFile(WorkHomeOrderAddActivity.path1, options);
            img2.setImageBitmap(bm);
        }

    }



    //这里是在签名页面退出的时候  将页面切换为正常的屏幕 即竖屏
    @Override
    protected void onResume() {

        if(getRequestedOrientation()!= ActivityInfo.SCREEN_ORIENTATION_PORTRAIT){
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        }
        super.onResume();
    }
}
